<?php
/*
 * Created on Sep 10, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */

class BlogController extends Application
{
	function __construct()
	{
		parent::__construct(null, null);
		$this->loadModel('PostModel');		
	}

	/**
	 * "accept_methods: get"
	 */
	function index()
	{
		$posts = $this->PostModel->getAll();
		$data['posts'] = $posts;
		$this->loadView('view_blog', $data);
	}

	function add($title="")
	{
		$this->getCookie()->clear('test_cookie');
		$this->loadHelper('HtmlHelper', 'html');
		$this->loadView('view_blog_add');
	}
	
	function savePost() {
		$title = $this->getRequest()->getParam('title');
		$this->PostModel->add($title, 'content 123');
		$this->getResponse()->redirect('/blog/index');
	}
}
?>
